package com.nbsaas.boot.iot.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

/**
 * IoT设备数据实体类
 * 
 * @author 系统生成
 */
@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "IoT设备数据", model = "IoT设备数据")
@Entity
@Table(name = "bs_iot_device_data")
@Comment("IoT设备数据表")
public class IotDeviceData extends AbstractEntity {

    @Comment("设备ID")
    @FormField(title = "设备ID", sortNum = "1", grid = true, type = InputType.select)
    @Column(name = "device_id")
    private Long deviceId;

    @Comment("数据类型")
    @SearchItem(name = "dataType", key = "dataType", label = "数据类型")
    @FormField(title = "数据类型", sortNum = "2", grid = true, type = InputType.select)
    @Column(name = "data_type", length = 50)
    private String dataType; // TEMPERATURE-温度, PRESSURE-压力, VIBRATION-振动, POWER_CONSUMPTION-功耗, HUMIDITY-湿度, LIGHT-光照

    @Comment("数据值")
    @FormField(title = "数据值", sortNum = "3", grid = true, type = InputType.el_input_number)
    @Column(name = "data_value", precision = 15, scale = 4)
    private BigDecimal dataValue;

    @Comment("单位")
    @FormField(title = "单位", sortNum = "4", grid = true)
    @Column(name = "unit", length = 20)
    private String unit;

    @Comment("采集时间")
    @FormField(title = "采集时间", sortNum = "5", type = InputType.date, grid = true)
    @Column(name = "collection_time")
    private Date collectionTime;

    @Comment("数据质量")
    @FormField(title = "数据质量", sortNum = "6", grid = true, type = InputType.select)
    @Column(name = "data_quality", length = 20)
    private String dataQuality; // EXCELLENT-优秀, GOOD-良好, FAIR-一般, POOR-差

    @Comment("数据状态")
    @FormField(title = "数据状态", sortNum = "7", grid = true, type = InputType.select)
    @Column(name = "data_status", length = 20)
    private String dataStatus; // NORMAL-正常, ABNORMAL-异常, ALERT-告警

    @Comment("阈值上限")
    @FormField(title = "阈值上限", sortNum = "8", grid = true, type = InputType.el_input_number)
    @Column(name = "threshold_upper", precision = 15, scale = 4)
    private BigDecimal thresholdUpper;

    @Comment("阈值下限")
    @FormField(title = "阈值下限", sortNum = "9", grid = true, type = InputType.el_input_number)
    @Column(name = "threshold_lower", precision = 15, scale = 4)
    private BigDecimal thresholdLower;

    @Comment("数据描述")
    @FormField(title = "数据描述", sortNum = "10", type = InputType.textarea)
    @Column(name = "description", length = 500)
    private String description;
} 